<#include "../common/layout/__mainlayout.html">

<#assign pageBreadCrumbs>
    <li class="active"><a href="#">系统管理</a></li>
    <li class="active">菜单资源</li>
</#assign>

<#assign pageCss>
    <!-- page specific plugin styles -->
    <link rel="stylesheet" href="${ctx}/static/admin/assets/css/jquery-ui.custom.css" />
    <link rel="stylesheet" href="${ctx}/static/admin/assets/css/chosen.css" />
    <link rel="stylesheet" href="${ctx}/static/admin/assets/css/datepicker.css" />
    <link href="${ctx}/static/admin/assets/treeTable/v3.0.0/css/jquery.treetable.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/static/admin/assets/treeTable/v3.0.0/css/jquery.treetable.theme.default.css" rel="stylesheet" type="text/css" />
</#assign>
<#assign pageJavascript>


<script src="${ctx}/static/admin/assets/treeTable/v3.0.0/js/jquery.treetable.js"> </script>
<script>
    $("#contentTable").treetable({expandable: true});
</script>

    <script type="text/javascript">
        $(document).ready(function(){

            if(!ace.vars['touch']) {
                $('.chosen-select').chosen({allow_single_deselect:true});
            }

            $("#editModal").on("hidden.bs.modal", function(){
                $(this).removeData("bs.modal");
            });

            // 删除按钮
            $("a.delete").on(ace.click_event, function(e){
                var currentA = this;
                e.preventDefault();
//                bootbox.setDefaults({locale:"zh_CN"});
                bootbox.confirm({
                            message: "确定删除该目录?",
                            buttons: {
                                confirm: {
                                    label: "确定",
                                    className: "btn-primary btn-sm"
                                },
                                cancel: {
                                    label: "取消",
                                    className: "btn-sm"
                                }
                            },
                            callback: function(result) {
                                if(result){
                                    $.ajax({
                                        type: "POST",
                                        url: $(currentA).attr("href"),
                                        dataType: 'text',
                                        success: function(msg){
                                            var msg = eval("("+msg+")");
                                            if(msg.result == "success"){
                                                window.location="${ctx}/admin/menu/list.html";
                                            }else{
                                                alert(msg.messages);
                                            }
                                        },
                                        error: function(){
                                            bootbox.alert("删除失败");
                                        }
                                    });
                                }
                            }
                        }
                );
            });
        });
    </script>
</#assign>

<@mainlayout pageBreadCrumbs=pageBreadCrumbs pageCss=pageCss pageJavascript=pageJavascript currentMenu="systemFlag-MyInfoFlag">
    <div class="row">
        <div class="col-xs-12">
            <form id="searchForm" action="${ctx}/admin/menu/list.html" class="form-search form-inline" method="GET">

                <a href="${ctx}/admin/menu/edit.html" class="btn btn-sm btn-warning" data-toggle="modal" data-target="#editModal"><i class="ace-icon fa fa-plus"></i>添加</a>

            <table id="contentTable" class="treetable table table-striped table-bordered table-hover">
                <thead>
                <tr>
                    <th width="100" align="center" >菜单名</th>
                    <th width="20" align="left" >菜单等级</th>
                    <th width="60" align="center" >菜单标识</th>
                    <th width="60" align="center" >菜单链接</th>
                    <th width="20" align="left" >排序号</th>
                    <th width="100" align="center" >操作</th>
                </tr>
                </thead>


                <tbody>
                        <#list menus as menu>
                            <#if menu??>
                            <tr class="">
                                <td width="20" align="left">
                                    <li class="dd-item">
                                        <span class="folder ui-draggable">${menu.name!}</span>
                                    </li>
                                </td>
                                <td width="20" align="left">${menu.level!}</td>
                                <td width="60" align="left">${menu.flag!}</td>
                                <td width="60" align="left">${menu.link!}</td>
                                <td width="20" align="left">${menu.sortIndex!}</td>
                                <td width="100" align="left">
                                    <a class="orange tooltip-success addSub" href="${ctx}/admin/menu/edit.html?id=${menu.id!}" data-rel="tooltip" title="编辑" data-toggle="modal" data-target="#editModal"><span class="label label-success">编辑</span></a>
                                    <a class="orange tooltip-success addSub" href="${ctx}/admin/menu/edit.html?parentId=${menu.id!}" data-rel="tooltip" title="添加子菜单" data-toggle="modal" data-target="#editModal"><span class="label label-success">添加子菜单</span></a>
                                    <#if menu.subMenuList??  || menu.isys == 1>
                                        <#else>
                                        <a class="red tooltip-error delete" href="${ctx}/admin/menu/delete.do?id=${menu.id!}" data-rel="tooltip" title="删除" ><span class="label label-danger">删除</span></a>
                                    </#if>
                                </td>
                            </tr>
                                <#if menu.subMenuList??>
                                    <#list menu.subMenuList as secMenu>
                                        <tr class="">
                                            <td width="20" align="left"  style="padding-left: 2em">
                                                <li class="dd-item">
                                                    <span class="folder ui-draggable">${secMenu.name!}</span>
                                                </li>
                                            </td>
                                            <td width="20" align="left">${secMenu.level!}</td>
                                            <td width="60" align="left">${secMenu.flag!}</td>
                                            <td width="60" align="left">${secMenu.link!}</td>
                                            <td width="20" align="left">${secMenu.sortIndex!}</td>
                                            <td width="100" align="left">
                                                <a class="orange tooltip-success addSub" href="${ctx}/admin/menu/edit.html?id=${secMenu.id!}" data-rel="tooltip" title="编辑" data-toggle="modal" data-target="#editModal"><span class="label label-success">编辑</span></a>
                                                <a class="orange tooltip-success addSub" href="${ctx}/admin/menu/edit.html?parentId=${secMenu.id!}" data-rel="tooltip" title="添加子菜单" data-toggle="modal" data-target="#editModal"><span class="label label-success">添加子菜单</span></a>
                                                <#if secMenu.subMenuList?? || menu.isys == 1>
                                                    <#else>
                                                    <a class="red tooltip-error delete" href="${ctx}/admin/menu/delete.do?id=${secMenu.id!}" data-rel="tooltip" title="删除" ><span class="label label-danger">删除</span></a>
                                                </#if>
                                            </td>
                                        </tr>
                                        <#if secMenu.subMenuList??>
                                            <#list secMenu.subMenuList as thirdMenu>
                                                <tr class="">
                                                    <td width="20" align="left"  style="padding-left: 4em">
                                                        <li class="dd-item">
                                                            <span class="folder ui-draggable">${thirdMenu.name!}</span>
                                                        </li>
                                                    </td>
                                                    <td width="20" align="left">${thirdMenu.level!}</td>
                                                    <td width="60" align="left">${thirdMenu.flag!}</td>
                                                    <td width="60" align="left">${thirdMenu.link!}</td>
                                                    <td width="20" align="left">${thirdMenu.sortIndex!}</td>
                                                    <td width="100" align="left">
                                                        <a class="orange tooltip-success addSub" href="${ctx}/admin/menu/edit.html?id=${thirdMenu.id!}" data-rel="tooltip" title="编辑" data-toggle="modal" data-target="#editModal"><span class="label label-success">编辑</span></a>
                                                        <a class="orange tooltip-success addSub" href="${ctx}/admin/menu/edit.html?parentId=${thirdMenu.id!}" data-rel="tooltip" title="添加子菜单" data-toggle="modal" data-target="#editModal"><span class="label label-success">添加子菜单</span></a>
                                                        <#if  menu.isys == 1>
                                                            <#else>
                                                            <a class="red tooltip-error delete" href="${ctx}/admin/menu/delete.do?id=${thirdMenu.id!}" data-rel="tooltip" title="删除" ><span class="label label-danger">删除</span></a>
                                                        </#if>
                                                    </td>
                                                </tr>
                                                <#if thirdMenu.subMenuList??>
                                                    <#list thirdMenu.subMenuList as fouthMenu>
                                                        <tr class="">
                                                            <td width="20" align="left"  style="padding-left: 6em">
                                                                <li class="dd-item">
                                                                    <span class="folder ui-draggable">${fouthMenu.name!}</span>
                                                                </li>
                                                            </td>
                                                            <td width="20" align="left">${fouthMenu.level!}</td>
                                                            <td width="60" align="left">${fouthMenu.flag!}</td>
                                                            <td width="60" align="left">${fouthMenu.link!}</td>
                                                            <td width="20" align="left">${fouthMenu.sortIndex!}</td>
                                                            <td width="100" align="left">
                                                            </td>
                                                        </tr>
                                                    </#list>
                                                </#if>
                                            </#list>
                                        </#if>
                                    </#list>
                                </#if>
                            </#if>
                        </#list>
                </tbody>
            </table>
            </form>
        </div>
    </div>

    <div id="editModal" class="modal fade" data-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content">
            </div>
        </div>
    </div>
</@mainlayout>